#ifndef PSFPrimaryGeneratorAction_h
#define PSFPrimaryGeneratorAction_h 1

#include "globals.hh"
#include "G4VUserPrimaryGeneratorAction.hh"

class PSFDetectorConstruction;
class PSFPrimaryGeneratorMessenger;

class G4Event;
class G4GeneralParticleSource;
class G4PhysicsTable;

class PSFPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
{
public:
  PSFPrimaryGeneratorAction(PSFDetectorConstruction *);
  ~PSFPrimaryGeneratorAction() override;

  void GeneratePrimaries(G4Event *) override;

  void BuildEmissionSpectrum();
  void SetOptPhotonPolar(G4double);
  void SetDecayTimeConstant(G4double);

  void SetUseSampledEnergy(G4bool v) { fUseSampledEnergy = v; }

protected:
  G4PhysicsTable *fIntegralTable = nullptr;

private:
  void SetOptPhotonPolar();
  void SetOptPhotonTime();

  PSFDetectorConstruction *fDetector = nullptr;
  G4GeneralParticleSource *fParticleGun = nullptr;
  PSFPrimaryGeneratorMessenger *fGunMessenger = nullptr;

  static G4bool fFirst;
  G4double fTimeConstant = 0.;
  G4bool fUseSampledEnergy = false;
};

#endif
